<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <title>客户管理</title>
  <link th:href="@{/css/style.css}" rel="stylesheet" type="text/css"/>
  <script type="text/javascript" th:src="@{/js/jquery.js}"></script>
  <script type="text/javascript">
    function tipOpen(content,num,status) {
      $(".tipright p").text(content);
      $("#tip").fadeIn(200);
      $("#customid").val(num);
      $("#status").val(status);
    }
    function tipClose() {
      $("#tip").fadeOut(200);
      var customid=$("#customid").val();
      var status=$("#status").val();
      location.href="/erp1/market/customer/editStatus?customid="+customid+"&status="+status;
    }

    function tipClose2() {
      $("#tip").fadeOut(200);
    }

  </script>
</head>

<body>
<div class="place"><span>位置：</span>
  <ul class="placeul">
    <li>营销管理</li>
    <li>客户管理</li>
    <li>基本内容</li>
  </ul>
</div>
<div class="rightinfo">
  <form id="customform" action="/erp1/market/customer/ulist" method="post">
    <input type="hidden" name="pageno" value="1" id="pageno"/>
    <ul class="tools">
      <li> 公司名称:
        <input type="text"  name="company" th:value="${custom.company}"/>
      </li>
      <li> 客户姓名:
        <input type="text" name="customname" th:value="${custom.customname}"/>
      </li>
      <li> 所属区域：
        <select name="customPid" onchange="getCity(this.value)">
          <option value="0">请选择省份</option>
          <option th:each="p:${session.provinces}" th:text="${p.pName}" th:value="${p.id}"
                  th:selected="${p.id==custom.customPid}"
          ></option>
        </select>
        <select name="address">
          <option value="0">请选择城市</option>
        </select>
      </li>
      <script th:inline="javascript">
        $('.tablelist tbody tr:odd').addClass('odd');

        $(function () {
          var num=$("select[name=firmPid]").val();
          getCity(num);
        });

        function goPage(num) {
          // alert(num);
          $("#pageno").val(num);
          $("#customform").submit();
        }



        function getCity(num) {
          $.get("/ajaxCity",{"pid":num},function (data) {
            console.log(data);
            $("select[name=address]").html("");
            var options="<option value=''>请选择城市</option>";
            var c=[[${custom.address}]];
            $.each(data,function (i,e) {
              if(e.id==c){
                options+="<option value='"+e.id+"' selected='selected'>"+e.cname+"</option>";
              }else{
                options+="<option value='"+e.id+"'>"+e.cname+"</option>";
              }
            });
            $("select[name=address]").append(options);
          },"json");
        }
      </script>

      <li class="subBut" onclick="goPage(1)"><img src="../../images/t06.png" />查询</li>
      </li>
    </ul>
    <table class="tablelist">
      <thead>
      <tr>
        <th>序号</th>
        <th>客户姓名</th>
        <th>性别</th>
        <th>联系电话</th>
        <th>所属公司</th>
        <th>所属区域</th>
        <th>状态</th>
        <th>创建时间</th>
        <th>创建人</th>
        <th>分配时间</th>
        <th>客服人员</th>
        <th>操作</th>
      </tr>
      </thead>
      <tbody>
      <tr th:each="c,i :${upage.list}">
        <td th:text="${(upage.pageNum-1)*upage.pageSize+i.count}">1</td>
        <td th:text="${c.customname}">王金平</td>
        <td th:text="${c.sex==1?'女':'男'}">男</td>
        <td th:text="${c.telephone}">17370899727</td>
        <td th:text="${c.company}">阿里巴巴</td>
        <td th:text="${c.address==null?'':c.city.provinces.pName+' '+c.city.cName}">江苏南京</td>
        <td th:text="${c.status==1?'可用':'不可用'}">可用</td>
        <td th:text="${#dates.format(c.createtime,'yyyy-MM-dd hh:MM:ss')}"></td>
        <td th:text="${c.createid==null?'':c.createUser.uname}">管理员</td>
        <td th:text="${#dates.format(c.distractime,'yyyy-MM-dd hh:MM:ss')}"></td>
        <td th:text="${c.serviceid==0?'':c.serviceUser.uname}"></td>
        <td>
          <a th:href="@{'/market/customer/find/'+${c.customid}}" class="tablelink">查看详情</a>
        </td>
      </tr>
      </tbody>
    </table>
    <div class="pagin">
      <div class="message">共<i class="blue" th:text="${upage.total}"></i>条记录，当前显示第&nbsp;<i class="blue" th:text="${upage.pageNum}">2&nbsp;</i>页</div>
      <ul class="paginList">
        <li class="paginItem">
          <a href="javascript:void(0);" th:onclick="goPage([[${upage.isFirstPage?1:upage.pageNum-1}]])">
            <span th:class="${upage.isFirstPage?'pagepre':'pagenxt roate'}"></span>
          </a>
        </li>
        <li th:class="${page==upage.pageNum?'paginItem current':'paginItem'}"
            th:each="page : ${upage.navigatepageNums}">
          <a href="javascript:;"  th:text="${page}" th:onclick="goPage([[${page}]])">1</a>
        </li>
        <li class="paginItem">
          <a href="javascript:void(0);" th:onclick="goPage([[${upage.isLastPage?upage.pages:upage.pageNum+1}]])">
            <span th:class="${upage.isLastPage?'pagepre roate':'pagenxt'}"></span>
          </a>
        </li>
      </ul>
    </div>
  </form>
  <!-- 提示框 -->
  <div id="tip" class="tip">
    <div class="tiptop"><span>提示信息</span><a onclick="tipClose()"></a></div>
    <div class="tipinfo"> <span><img th:src="@{/images/ticon.png}" /></span>
      <div class="tipright">
        <p></p>
        <cite>如果是请点击确定按钮 ，否则请点取消。</cite> </div>
    </div>
    <div class="tipbtn">
      <input type="button"  class="sure" value="确定" onclick="tipClose()" />
      &nbsp;
      <input type="button"  class="cancel" value="取消" onclick="tipClose()" />
    </div>
  </div>
</div>
</div>
</body>
</html>